
package com.hlkj.pay.config;
/*
 * Hlpay-Plus aggregate payment system.
 * Copyright (c) 2024-2025 Hlpay Team Copyright has the right of final interpretation.
 */

import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

import com.hlkj.pay.interceptor.ClientTokenInterceptor;

import lombok.RequiredArgsConstructor;

/**
 * @author HlpayTeam
 * @date 2024/10/09 13:59
 */
@EnableWebMvc
@Configuration
@RequiredArgsConstructor
public class ClientApiInterceptorConfigurer implements WebMvcConfigurer {

    private final ClientTokenInterceptor clientTokenInterceptor;

    private final InterceptorProperties interceptorProperties;

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(clientTokenInterceptor).addPathPatterns(interceptorProperties.getClientApiTokenUrl())
                .excludePathPatterns(interceptorProperties.getIgnoreClientApiTokenUrl()).excludePathPatterns(interceptorProperties.getCallBackApiTokenUrl())
                .excludePathPatterns("/v1/openapi/user/sendAuthCode", "/v1/openapi/user/login");
    }
}
